package com.allenkerr.model;

import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.*;
import org.springframework.data.elasticsearch.core.geo.GeoPoint;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.annotation.JsonNaming;

@Document(indexName = "es-book", type = "book")
public class Book {

  @Id
  private String id;
  private String title;

  @Field(analyzer = "ik_smart", type = FieldType.String)
  private String author;

  @Field(index = FieldIndex.not_analyzed, type = FieldType.String)
  private String releaseDate;

  private GeoPoint location;

  @GeoPointField
  private String geoLocationStr;

  public Book() {
  }

  public Book(String title, String author, String releaseDate) {
    this.title = title;
    this.author = author;
    this.releaseDate = releaseDate;
  }

  public Book(String id, String title, String author, String releaseDate) {
    this.id = id;
    this.title = title;
    this.author = author;
    this.releaseDate = releaseDate;
  }

  public Book(String id, String title, String author, String releaseDate, GeoPoint location) {
    this.id = id;
    this.title = title;
    this.author = author;
    this.releaseDate = releaseDate;
    this.location = location;
  }

  public Book(String id, String title, String author, String releaseDate, String geoLocationStr) {
    this.id = id;
    this.title = title;
    this.author = author;
    this.releaseDate = releaseDate;
    this.geoLocationStr = geoLocationStr;
  }

  public Book(String id, String title, String author, String releaseDate, GeoPoint location, String geoLocationStr) {
    this.id = id;
    this.title = title;
    this.author = author;
    this.releaseDate = releaseDate;
    this.location = location;
    this.geoLocationStr = geoLocationStr;
  }

  @Override
  public String toString() {
    return "Book{" +
            "id='" + id + '\'' +
            ", title='" + title + '\'' +
            ", author='" + author + '\'' +
            ", releaseDate='" + releaseDate + '\'' +
            ", location=" + location +
            '}';
  }

  public String getId() {
    return id;
  }

  public void setId(String id) {
    this.id = id;
  }

  public String getTitle() {
    return title;
  }

  public void setTitle(String title) {
    this.title = title;
  }

  public String getAuthor() {
    return author;
  }

  public void setAuthor(String author) {
    this.author = author;
  }

  public String getReleaseDate() {
    return releaseDate;
  }

  public void setReleaseDate(String releaseDate) {
    this.releaseDate = releaseDate;
  }

  public GeoPoint getLocation() {
    return location;
  }

  public void setLocation(GeoPoint location) {
    this.location = location;
  }

  public String getGeoLocationStr() {
    return geoLocationStr;
  }

  public void setGeoLocationStr(String geoLocationStr) {
    this.geoLocationStr = geoLocationStr;
  }
}